package cn.legend.travel.admin.comment.dao.persist.repository.impl;

import cn.hutool.extra.spring.SpringUtil;
import cn.legend.travel.admin.comment.dao.persist.mapper.CommentMapper;
import cn.legend.travel.admin.comment.dao.persist.repository.ICommentRepository;
import cn.legend.travel.admin.comment.pojo.vo.CommentCheckVO;
import cn.legend.travel.common.pojo.vo.PageData;
import cn.legend.travel.common.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Repository;

@Repository
public class CommentRepositoryImpl implements ICommentRepository {

    @Override
    public PageData<CommentCheckVO> getCommentList(String type, Integer pageNum, Integer pageSize) {
        CommentMapper mapper = SpringUtil.getBean(type);
        PageHelper.startPage(pageNum, pageSize);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(mapper.getList()));
    }

    @Override
    public int deleteById(String type, Long id) {
        CommentMapper mapper = SpringUtil.getBean(type);
        return mapper.deleteById(id);
    }

    @Override
    public int passById(String type, Long id) {
        CommentMapper mapper = SpringUtil.getBean(type);
        return mapper.passById(id);
    }
}
